//
//  ZDOrderCell.m
//  特种车调度
//
//  Created by 陈宇 on 15/8/18.
//
//

#import "ZDOrderCell.h"

@interface ZDOrderCell ()

@property (weak, nonatomic) IBOutlet UIButton *orderNoButton;
@property (weak, nonatomic) IBOutlet UIButton *dateButton;
@property (weak, nonatomic) IBOutlet UIButton *carStyleButton;
@property (weak, nonatomic) IBOutlet UIButton *transNumButton;
@property (weak, nonatomic) IBOutlet UIButton *distanceeButton;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *statusLabel;
@property (weak, nonatomic) IBOutlet UILabel *countLabel;
@property (weak, nonatomic) IBOutlet UIButton *singlePriceButton;

@end

@implementation ZDOrderCell

- (void)awakeFromNib {
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

- (void)setOrder:(ZDOrder *)order
{
    _order = order;
    
    [self.orderNoButton setTitle:[NSString stringWithFormat:@"订单号 %@", _order.orderNum] forState:UIControlStateNormal];
    [self.dateButton setTitle:[NSString stringWithFormat:@"用车时间：%@", _order.appointmentTime] forState:UIControlStateNormal];
    [self.carStyleButton setTitle:[NSString stringWithFormat:@"需求车型：%@(%ld辆)", _order.style1, _order.count] forState:UIControlStateNormal];
    [self.transNumButton setTitle:[NSString stringWithFormat:@"需求方量：%.1f方", _order.volume] forState:UIControlStateNormal];
    [self.distanceeButton setTitle:[NSString stringWithFormat:@"%@：%@", _order.conditionName, _order.condition] forState:UIControlStateNormal];
    self.priceLabel.text = [NSString stringWithFormat:@"￥%.1f", _order.sumPrice];
    self.countLabel.text = @(_order.robCount).description;
    self.statusLabel.textColor = _order.orderColor;
    self.statusLabel.text = _order.orderTitle;
    
    double singlePrice = _order.sumPrice / _order.volume;
    
    [self.singlePriceButton setTitle:[NSString stringWithFormat:@"方量单价：%.1f元/方", singlePrice] forState:UIControlStateNormal];
}

@end
